<template>
  <div class="ipt">
    <div class="add">
      编号<input type="text" v-model="code" /> 品牌名称:<input
        type="text"
        v-model="productName"
      />
      <br />
      产品图片地址:<input type="text" v-model="imgSrc" />

      价格:<input type="text" v-model="price" />
      <button @click="add">添加</button>
    </div>

    <div class="add">
      品牌名称:<input
        type="text"
        placeholder="请输入搜索条件"
        v-model="productName"
      />
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      code: "",
      productName: "",
      imgSrc: "",
      price: "",
    };
  },
  methods: {
    add() {
      if (!this.code || !this.imgSrc || !this.price || !this.productName) {
        return;
      }
      let obj = {
        id: Math.random().toString(32).substring(2),
        code: this.code,
        productName: this.productName,
        imgSrc:
          "https://tse1-mm.cn.bing.net/th/id/R-C.fc48d5b3c65b7b79980ab09dfc2890d8?rik=jy07dRFBQAwjzw&riu=http%3a%2f%2f5b0988e595225.cdn.sohucs.com%2fimages%2f20190322%2fe2edee9d2ee847f0b564fcbadf356a46.jpeg&ehk=cKT9XpGfozyLcO5sia93t8gLeJurN9RM%2boqkkCk6a7Q%3d&risl=&pid=ImgRaw&r=0&sres=1&sresct=1",
        price: this.price,
        total: this.price,
        count: 1,
      };
      this.$emit("add", obj);
    },
  },
};
</script>
